package com.example.base.base.activity

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.therouter.TheRouter

/**
 * @Description
 * @department 城市元宇宙组
 * @Author niushilong
 * @Date 2024-03-31 15:11
 */
abstract class BaseActivity : AppCompatActivity() {

    /**
     * 获取context
     */
    protected lateinit var mActivity: Activity
    protected lateinit var mContext: Context

    abstract fun init()

    abstract fun setContentView()

    protected open fun getDataFromIntent(intent: Intent){}

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView()
        mContext = this.applicationContext
        mActivity = this
        // 通过TheRouter接收对象必须调用这一句
        TheRouter.inject(this)

        if (intent != null){
            getDataFromIntent(intent)
        }

        init()
    }

    override fun attachBaseContext(newBase: Context?) {
        TheRouter.isDebug = true
        super.attachBaseContext(newBase)
    }
}